package com.nantian.logic.controller.mainControl.articalControl;

import com.cuit.springboot.gdao.common.ArticleHtmlMapper;
import com.nantian.logic.utils.MapUtils;
import com.nantian.logic.utils.UniversalResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("article")
public class ArticalHtmlController {
    @Autowired
    ArticleHtmlMapper articleHtmlMapper;

    @PostMapping(value = "update")
    @PreAuthorize("hasRole('AE')")
    public UniversalResult update(@RequestBody Map<String,Object> resultMap){
        if (!MapUtils.checkKeyIsNull(resultMap,"articleId","content")){
            articleHtmlMapper.updateByArticleId(resultMap);
            return new UniversalResult<>(UniversalResult.SUCCESS,"更新成功");
        }
        else {
            return new UniversalResult<>(UniversalResult.PARAM_ERROR,"请求参数有误");
        }
    }
}








